package de.mud.jta;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;

public class JSchResourceManager 
{
    private static JSchResourceManager rm;
    private ResourceBundle rb;
    private Locale locale;

    public Locale getLocale() 
    {
		return locale;
	}

	private JSchResourceManager()
    {
    	locale = ResourceManager.getInstance().getLocale();
    	rb = ResourceBundle.getBundle("de.mud.jta.resources.JtaJsch",locale);
    }

    public static JSchResourceManager getInstance()
    {
	if (rm == null)
	{
	    rm = new JSchResourceManager();
	}
	return rm;
    }

    public String getString(String key)
    {
	String str = rb.getString(key);
	if (str != null)
	{
	    return str;
	}
	return key;
    }

    public String getString(String key, String param)
    {
	String str = rb.getString(key);
	if (str != null)
	{
	    return MessageFormat.format(str, new String[]{ param });
	}
	return key;
    }

    public String getString(String key, String param1, String param2)
    {
	String str = rb.getString(key);
	if (str != null)
	{
	    return MessageFormat.format(str, new String[]{ param1, param2 });
	}
	return key;
    }

    public String getString(String key, String params[])
    {
	String str = rb.getString(key);
	if (str != null)
	{
	    return MessageFormat.format(str, params);
	}
	return key;
    }

}
